package cn.fl.project.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.user.facade.system.api.ISysOrgApiService;
import cmm.user.facade.system.dto.SysOrgDTO;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.commons.result.ResponseData;
import cn.fl.customer.service.ICstBscInfoService;
import cn.fl.customer.vo.CstBscInfoVO;
import cn.fl.framework.base.constant.WebBaseConstant;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.framework.constant.DictionaryConstant;
import cn.fl.preloan.IProjectProductMortgateService;
import cn.fl.preloan.condition.PrjPrdMtgQueryCondition;
import cn.fl.preloan.dto.DeleteByIdsProjProdMortgageRequest;
import cn.fl.preloan.dto.PrjPrdMtgDTO;
import cn.fl.preloan.dto.PrjPrdMtgPageResponseDTO;
import cn.fl.preloan.enums.PreloanResultCodeEnum;
import cn.fl.project.condition.PrjBscInfoQueryCondition;
import cn.fl.project.condition.PrjPrdBscInfoQueryCondition;
import cn.fl.project.constant.PrjBscInfoConstant;
import cn.fl.project.constant.PrjPrdMtgConstant;
import cn.fl.project.service.*;
import cn.fl.project.vo.*;
import cn.fl.ref.fribaseinfo.service.IFriBaseInfoService;
import cn.fl.ref.fribaseinfo.vo.FriBaseInfoVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.vo.SysUlFilesRecVO;
import cn.fl.upload.constant.UploadConstant;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.ref.fribaseinfo.condition.FriBaseInfoQueryCondition;
import fl.ref.fribaseinfo.constant.FriBaseInfoConstant;
import fl.ref.fribaseinfo.dto.FriBaseInfoDTO;
import fl.ref.fribaseinfo.service.IFriBaseInfoApiService;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Description: 项目产品抵押信息表 控制层
 */
@Controller
@RequestMapping("/project/prjprdmtg")
public class PrjPrdMtgController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(PrjPrdMtgController.class);

	/**
	 * PrjPrdMtg 服务层BEAN
	 */
	@Autowired
	private IPrjPrdMtgService prjPrdMtgService;


	/**
	 * 产品明细
	 */
	@Autowired
	private IPrjPrdDtlService prjPrdDtlService;

	/**
	 * 项目
	 */
	@Autowired
	private IPrjBscInfoService prjBscInfoService;
	
	/**
	 * 合格证信息
	 */
	@Autowired
	private IPrjPrdVehInfoService prjPrdVehInfoService;
	/**
	 * 客户
	 */
	@Autowired
	private ICstBscInfoService cstBscInfoService ;
	/**
	 * 组织机构
	 */
	@Autowired
	private ISysOrgApiService sysOrgApiService ;
	@Autowired
	private ISysDictionaryApiService sysDictionaryApiService;
	@Autowired
	private IProjectProductMortgateService productMortgateService;
	@Autowired
    private IFriBaseInfoService friBaseInfoService;
	@Autowired
	private IPrjPrdPaySchMService prjPrdPaySchMService;
	@Autowired
    private IPrjPrdBscInfoService prjPrdBscInfoService;
	/**
	 * 融资机构基础信息
	 */
	@Autowired
	private IFriBaseInfoApiService friBaseInfoApiService;

	/**
	 * 到系统运维列表页面
	 */
	@RequestMapping(value = "/toListPage4Sys.do", method = {RequestMethod.GET})
	public ModelAndView toListPage4Sys(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("project/prjprdmtg/prjPrdMtgListPage4Sys");
		//抵押状态
		List<KeyValueVO> guarStsCdList = this.prjPrdMtgService.getGuarStsCdList();//抵押状态
		//抵押方式
		List<KeyValueVO> mtgWayList = this.sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_WAY_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
		//抵押名称与资方机构
		List<KeyValueVO> mtgInsList = this.sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_WAY_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
		view.addObject("mtgInsList", mtgInsList);
		view.addObject("mtgWayList", mtgWayList);
		view.addObject("guarStsCdList", guarStsCdList);
		BaseLogUtils.info(logger, "toListPage", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET})
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("project/prjprdmtg/prjPrdMtgListPage");
		//抵押状态
		List<KeyValueVO> guarStsCdList = this.prjPrdMtgService.getGuarStsCdList();//抵押状态
		//抵押方式
		List<KeyValueVO> mtgWayList = this.sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_WAY_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd()); 
		//抵押名称与资方机构
		List<KeyValueVO> mtgInsList = this.sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_INS_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
		view.addObject("guarStsCdList", guarStsCdList);
		view.addObject("mtgInsList", mtgInsList);
		view.addObject("mtgWayList", mtgWayList);
		BaseLogUtils.info(logger, "toListPage", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 到抵押预警列表页面
	 */
	@RequestMapping(value = "/toWarnListPage.do", method = { RequestMethod.GET})
	public ModelAndView toWarnListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("project/prjprdmtg/prjPrdMtgWarnListPage");
		//我司抵押状态
		List<KeyValueVO> guarStsCdList = this.prjPrdMtgService.getGuarStsCdList();//抵押状态
		//抵押方式
		List<KeyValueVO> mtgWayList = this.sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_WAY_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
		//三方机构
		Pager page = new Pager();
        page.setCurrentPage(1);
        page.setEveryPage(Integer.MAX_VALUE);
        FriBaseInfoQueryCondition qc = new FriBaseInfoQueryCondition();
        qc.setInsSts(FriBaseInfoConstant.FRI_BASE_INFO_INS_STS_PASS);
        qc.setInsUseCd("2");
        qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
        qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
        page.setCondition(qc);
		Pager pager = this.friBaseInfoService.searchListPage(page);
        List<FriBaseInfoVO> friBaseList = (List<FriBaseInfoVO>) pager.getResultList();
        //抵押预警状态
		List<KeyValueVO> mtgWarnList = this.sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_WARN_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
		//资方抵押状态
		List<KeyValueVO> mtgZgGuarList = this.sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_ZGGUAR_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
		view.addObject("mtgWarnList", mtgWarnList);
        view.addObject("friBaseList", friBaseList);
		view.addObject("guarStsCdList", guarStsCdList);
		view.addObject("mtgWayList", mtgWayList);
		view.addObject("mtgZgGuarList", mtgZgGuarList);
		BaseLogUtils.newLogger("toWarnListPage-跳转到列表页面.").info();
		return view;
	}

	/**
	 * 系统运维的到添加页面
	 */
	@RequestMapping(value = "/toAddPage4Sys.do", method = {RequestMethod.GET, RequestMethod.POST})
	public ModelAndView toAddPage4Sys(HttpServletRequest request, HttpServletResponse response) {
		String sysCd = CurrentThreadContext.getCurrentSysCd();
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		String id = request.getParameter("id");
		String dtlId = request.getParameter("dtlId");//明细ID
		String detailFlag = request.getParameter("detailFlag");//是否为详细页面
		String isFlow = request.getParameter("isFlow");//是否为流程中跳转页面
		String checkDy = request.getParameter("checkDy");//是否有验证抵押信息的权限
		ModelAndView view = new ModelAndView("project/prjprdmtg/prjPrdMtgAddPage4Sys");
		/*//查询登记编号历史数据
		PrjPrdMtgQueryCondition qc1 = new PrjPrdMtgQueryCondition();
		List<PrjPrdMtgVO> searchListrecNo = this.prjPrdMtgService.searchList(qc1);
		for (PrjPrdMtgVO prjPrdMtgVO : searchListrecNo) {
			String LSrecNo = prjPrdMtgVO.getRecNo();//登记编号
			view.addObject("LSrecNo", LSrecNo);
		}*/
		view.addObject("isFlow", isFlow);
		view.addObject("checkDy", checkDy);
		PrjPrdMtgVO mtg = null;
		PrjPrdDtlVO dtl = null;
		CstBscInfoVO cst = null;
		String no = "";
		String buOrgCd = "";
		String mtgDesc = "";
		String lnkCompNm = "";//挂靠公司名称
		String certType = PropertiesCacheUtils.getProperty(PrjPrdMtgConstant.CODE_MTG_CERT_TYP);
		String certNo = PropertiesCacheUtils.getProperty(PrjPrdMtgConstant.CODE_MTG_CERT_NO);
		String cstTypCd = "";
		if (StringUtils.isNotBlank(id)) {
			mtg = this.prjPrdMtgService.selectById(Long.valueOf(id));
		}
		//抵押权人名称数据字典查询
		List<KeyValueVO> pledgeeNmList = this.sysDictionaryApiService.getKvList(DictionaryConstant.CODE_PLEDGEE_NM, sysCd, orgCd);
		view.addObject("pledgeeNmList", pledgeeNmList);
		if (StringUtils.isNotBlank(dtlId)) {
			//查找产品信息
			dtl = this.prjPrdDtlService.selectById(Long.valueOf(dtlId));//产品明细信息
			//查找客户信息
			if (null != dtl) {
				String prdStsCd = dtl.getPrdStsCd();//查询资产状态
				view.addObject("prdStsCd", prdStsCd);
				//支付表号
				if (StringUtils.isNotBlank(dtl.getPaySchNo())) {
					String[] paySchNoStr = dtl.getPaySchNo().split("-");
					if (Integer.valueOf(paySchNoStr[paySchNoStr.length - 1]) < 10) {
						no = "0" + paySchNoStr[paySchNoStr.length - 1];
					} else {
						no = paySchNoStr[paySchNoStr.length - 1];
					}
				}
				//描述=产品名称+车架号+客户经理组织架构名称
				if (StringUtils.isNotBlank(dtl.getPrdNm())) {
					mtgDesc += dtl.getPrdNm();
				}
				//挂靠公司名称
				if (StringUtils.isNotBlank(dtl.getLnkCompNm())) {
					lnkCompNm = dtl.getLnkCompNm();
				}
				PrjBscInfoVO prjBsc = prjBscInfoService.selectById(dtl.getPrjId());
				if (null != prjBsc) {
					String prjTypCd = prjBsc.getPrjTypCd();//项目类型查询
					view.addObject("prjTypCd", prjTypCd);
					String insCode = prjBsc.getInsCode();//机构标识
					view.addObject("insCode", insCode);
					cst = this.cstBscInfoService.selectDetailById(prjBsc.getCstId());
					if (null != cst && StringUtils.isNotBlank(cst.getCstTypCd())) {
						cstTypCd = cst.getCstTypCd();
					}
					if (StringUtils.isNotBlank(prjBsc.getBuOrgCd())) {
						buOrgCd = prjBsc.getBuOrgCd();
						if (buOrgCd.equals(PrjBscInfoConstant.CODE_BU_ORG_CD_ZK)) {
							//查询合格证的vin
							if (null != dtl.getActPrdId()) {
								PrjPrdVehInfoVO veh = this.prjPrdVehInfoService.selectById(dtl.getActPrdId());
								if (null != veh && StringUtils.isNotBlank(veh.getVin())) {
									mtgDesc += veh.getVin();
								}
							}
						}
						if (buOrgCd.equals(PrjBscInfoConstant.CODE_BU_ORG_CD_QCJR)) {
							if (StringUtils.isNotBlank(dtl.getVin())) {
								mtgDesc += dtl.getVin();
							}
						}
					}
					//客户经理事业部
					if (StringUtils.isNotEmpty(prjBsc.getCstMgrOrgCd())) {
						String orgName = this.sysOrgApiService.selectSysOrgNmByOrgCd(prjBsc.getCstMgrOrgCd(), CurrentThreadContext.getCurrentSysCd());
						mtgDesc += orgName;
					}
				}
			}
		}

		//add 抵押名称与资方机构
		List<KeyValueVO> mtgInsList =this.sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_INS_CD,sysCd, orgCd);
		List<SysDictionaryDTO> mtgInsList1 =this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(),
				CurrentThreadContext.getCurrentOrgCd(), PrjPrdMtgConstant.CODE_MTG_INS_CD);
		//抵押方式
		List<KeyValueVO> mtgWayList =this.sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_WAY_CD, sysCd, orgCd);

		List<KeyValueVO> guarStsCdList = this.prjPrdMtgService.getGuarStsCdList();
		List<KeyValueVO> guarTypCdList = this.prjPrdMtgService.getGuarTypCdList();
		List<KeyValueVO> mtgPsnTypCdList = this.prjPrdMtgService.getMtgPsnTypCdList();
		List<KeyValueVO> yesNoList = this.prjPrdMtgService.getYesNoList();



		List<PrjPrdDtlVO> list = new ArrayList<PrjPrdDtlVO>();
		list.add(dtl);
		ListPageVO<PrjPrdDtlVO> dtlData = new ListPageVO<PrjPrdDtlVO>(list, 0);
		view.addObject("id", id);
		view.addObject("mtg", mtg);
		//view.addObject ("mtg", mtg);
		view.addObject("mtgDesc", mtgDesc);
		view.addObject("certType", certType);
		view.addObject("certNo", certNo);
		view.addObject("cst", cst);
		view.addObject("guarStsCdList", guarStsCdList);
		view.addObject("guarTypCdList", guarTypCdList);
		view.addObject("mtgPsnTypCdList", mtgPsnTypCdList);
		view.addObject("yesNoList", yesNoList);
		view.addObject("dtlId", dtlId);
		view.addObject("detailFlag", detailFlag);
		view.addObject("dtlData", JSON.toJSONString(dtlData));
		view.addObject("buOrgCd", buOrgCd);
		view.addObject("no", no);
		view.addObject("lnkCompNm", lnkCompNm);
		view.addObject("cstTypCd", cstTypCd);
		view.addObject("mtgWayList", mtgWayList);//add 抵押方式
		view.addObject("mtgInsList", mtgInsList);//抵押名称与资方机构
		view.addObject("mtgInsJsonArray",JSONArray.fromObject(mtgInsList1));//add 抵押名称与资方机构
		BaseLogUtils.info(logger, "toModifyPage", "跳转到修改页面.[id=" + id + "]", CurrentThreadContext.getCurrentUserName());
		return view;
	}

/**
	 * 到查看页面
	 */
	@RequestMapping(value = "/toViewPage.do")
	public ModelAndView toViewPage(HttpServletRequest request, HttpServletResponse response) {
		return this.toAddPage(request, response);
	}

	/**
	 * 到添加页面
	 */
	@RequestMapping(value = "/toAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		String id = request.getParameter("id");
		String dtlId = request.getParameter("dtlId");//明细ID
		String detailFlag = request.getParameter("detailFlag");//是否为详细页面
		String isFlow = request.getParameter("isFlow");//是否为流程中跳转页面
		String checkDy = request.getParameter("checkDy");//是否有验证抵押信息的权限
        String checkDyPass = request.getParameter("checkDyPass");//是否有验证抵押信息的权限
        String prjId = request.getParameter("prjId");
        String isQZ = request.getParameter("isQZ");//是否跳转页面是权证        
		ModelAndView view = new ModelAndView("project/prjprdmtg/prjPrdMtgAddPage");
		//查询登记编号历史数据dtlData
		/*PrjPrdMtgQueryCondition qc1 = new PrjPrdMtgQueryCondition();
		List<PrjPrdMtgVO> searchListrecNo = this.prjPrdMtgService.searchList(qc1);
		for (PrjPrdMtgVO prjPrdMtgVO : searchListrecNo) {
			String LSrecNo = prjPrdMtgVO.getRecNo();//登记编号
			view.addObject("LSrecNo", LSrecNo);
		}*/
		view.addObject("isQZ", isQZ);
		view.addObject("isFlow", isFlow);
		view.addObject("checkDy", checkDy);
		PrjPrdMtgVO mtg = null;
		PrjPrdDtlVO dtl = null;
		CstBscInfoVO cst = null;
		String no = "";
		String buOrgCd = "";
		String mtgDesc = "";
		String lnkCompNm = "";//挂靠公司名称
		String  certType = PropertiesCacheUtils.getProperty(PrjPrdMtgConstant.CODE_MTG_CERT_TYP);
		String  certNo = PropertiesCacheUtils.getProperty(PrjPrdMtgConstant.CODE_MTG_CERT_NO);
		String cstTypCd = "";
		String insCode = "";
		Integer isInsBiz = 0;
		String insName = "";
		Long fundRasInsId = null;
		if(StringUtils.isNotBlank(id)){
			 mtg =	this.prjPrdMtgService.selectById(Long.valueOf(id));
			 if (mtg==null) {
				id="";
			 }
		}

		//抵押权人名称数据字典查询
		List<KeyValueVO> pledgeeNmList = this.sysDictionaryApiService.getKvList(DictionaryConstant.CODE_PLEDGEE_NM, sysCd, orgCd);
		view.addObject("pledgeeNmList", pledgeeNmList);
		if(StringUtils.isNotBlank(dtlId)){
			 //查找产品信息
			 dtl =  this.prjPrdDtlService.selectById(Long.valueOf(dtlId));//产品明细信息
			 //查找客户信息
			 if(null!=dtl){
				 String prdStsCd = dtl.getPrdStsCd();//查询资产状态
					view.addObject("prdStsCd",prdStsCd);
					 //支付表号
					 if(StringUtils.isNotBlank(dtl.getPaySchNo())){
						 String[] paySchNoStr = dtl.getPaySchNo().split("-");
						 if(Integer.valueOf(paySchNoStr[paySchNoStr.length-1])<10){
							 no = "0"+paySchNoStr[paySchNoStr.length-1];
						 }else{
							 no =  paySchNoStr[paySchNoStr.length-1];
						 }
					 }
				 //描述=产品名称+车架号+客户经理组织架构名称
				 if(StringUtils.isNotBlank(dtl.getPrdNm())){
					 mtgDesc+=dtl.getPrdNm();
				 }
				 //挂靠公司名称
				 if(StringUtils.isNotBlank(dtl.getLnkCompNm())){
					 lnkCompNm = dtl.getLnkCompNm();
				 }
				 Long projectId = dtl.getPrjId();
				 if (projectId == null && StringUtils.isNotEmpty(prjId)) {
					 projectId = Long.valueOf(prjId);
				 }
				 PrjBscInfoVO prjBsc =  prjBscInfoService.selectById(projectId);
				 if(null!=prjBsc){
					 //机构标识
					 insCode = prjBsc.getInsCode();
					 insName = prjBsc.getFundRasInsNm();
					 isInsBiz = prjBsc.getIsInsBiz();
					 fundRasInsId = prjBsc.getFundRasInsId();
					 String prjTypCd = prjBsc.getPrjTypCd();//项目类型查询
					 view.addObject("prjTypCd",prjTypCd);
					 view.addObject("insCode", insCode);
					 view.addObject("insName", insName);
					 cst = this.cstBscInfoService.selectDetailById(prjBsc.getCstId());
					 if(null!=cst&&StringUtils.isNotBlank(cst.getCstTypCd())){
						 cstTypCd = cst.getCstTypCd();
					 }
					 if(StringUtils.isNotBlank(prjBsc.getBuOrgCd())){
						 buOrgCd = prjBsc.getBuOrgCd();
						 if(buOrgCd.equals(PrjBscInfoConstant.CODE_BU_ORG_CD_ZK)){
							 //查询合格证的vin
							 if(null!=dtl.getActPrdId()){
								 PrjPrdVehInfoVO veh =  this.prjPrdVehInfoService.selectById(dtl.getActPrdId());
								 if(null!=veh&&StringUtils.isNotBlank(veh.getVin())){
									 mtgDesc+=veh.getVin();
								 }
							 }
						 }
						 if(buOrgCd.equals(PrjBscInfoConstant.CODE_BU_ORG_CD_QCJR)){
							 if(StringUtils.isNotBlank(dtl.getVin())){
								 mtgDesc+=dtl.getVin();
							 }
						 }
					 }
					 //客户经理事业部
					 if(StringUtils.isNotEmpty(prjBsc.getCstMgrOrgCd())){
						 String orgName = this.sysOrgApiService.selectSysOrgNmByOrgCd(prjBsc.getCstMgrOrgCd(),CurrentThreadContext.getCurrentSysCd());
						 mtgDesc+= orgName;
					 }				
				 }
			 }
		}
		//add 抵押名称与资方机构   by gengchunlan 20190731
//		List<KeyValueVO> mtgInsList =this.sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_INS_CD,sysCd, orgCd);
		List<SysDictionaryDTO> mtgInsList1 =this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(),
				CurrentThreadContext.getCurrentOrgCd(), PrjPrdMtgConstant.CODE_MTG_INS_CD);
		//抵押方式
		List<KeyValueVO> mtgWayListAll = sysDictionaryApiService.getKvList(PrjPrdMtgConstant.CODE_MTG_WAY_CD, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
		List<SysDictionaryDTO> mtgNmList = sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), PrjPrdMtgConstant.CODE_MTG_WAY_CD);

		//抵押方式
		List<KeyValueVO> mtgWayList = new ArrayList<>();
		//抵押方式对应的签字和抵押权人名称
		List<KeyValueVO> mtgInsList = new ArrayList<>();
		for (SysDictionaryDTO dictionaryDTO : mtgNmList){
			KeyValueVO kv = new KeyValueVO();
			kv.setKey(dictionaryDTO.getCode());
			if ("4".equals(dictionaryDTO.getCode())){
				kv.setValue(insName + "_" + dictionaryDTO.getCodeAttr1());
			}else {
				kv.setValue(dictionaryDTO.getCodeDesc() + "_" + dictionaryDTO.getCodeAttr1());
			}
			mtgInsList.add(kv);
		}
		//资管机构抵押方式取资管机构管理中的配置
		if (BaseConstant.IS_YESNO_YES == isInsBiz && null != fundRasInsId){
			BaseLogUtils.newLogger("查询资管机构抵押配置信息Start：prjId={},fundRasInsId={},sysCd={},orgCd={}", prjId,fundRasInsId,CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentBuOrgCd()).info();
			FriBaseInfoDTO friBaseInfoDTO = friBaseInfoApiService.selectById(fundRasInsId, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
			BaseLogUtils.newLogger("查询资管机构抵押配置信息End:friBaseInfoDTO={}", JSON.toJSONString(friBaseInfoDTO)).info();
			if (null != friBaseInfoDTO && StringUtils.isNotEmpty(friBaseInfoDTO.getmTgWay())){
				String mtgWay = friBaseInfoDTO.getmTgWay();
				mtgWayList = mtgWayListAll.stream().filter(way -> mtgWay.contains(way.getKey())).collect(Collectors.toList());
				mtgInsList = mtgInsList.stream().filter(ins -> mtgWay.contains(ins.getKey())).collect(Collectors.toList());
			}else {
				mtgWayList = mtgWayListAll;
			}
		}else {
			//非资管，移除”资方机构“抵押方式
			mtgWayListAll.removeIf(way -> "4".equals(way.getKey()));
			mtgWayList = mtgWayListAll;
			mtgInsList.removeIf(ins -> "4".equals(ins.getKey()));
		}
		BaseLogUtils.newLogger("支持的抵押方式列表mtgWayList={}，抵押签字_抵押权人名称={}", JSON.toJSONString(mtgWayList), JSON.toJSONString(mtgInsList)).info();

		//end by gengchunlan 20190731
		List<KeyValueVO> guarStsCdList =  this.prjPrdMtgService.getGuarStsCdList();
		List<KeyValueVO> guarTypCdList = this.prjPrdMtgService.getGuarTypCdList();
		List<KeyValueVO> mtgPsnTypCdList = this.prjPrdMtgService.getMtgPsnTypCdList();
		List<KeyValueVO> yesNoList = this.prjPrdMtgService.getYesNoList();
		List<PrjPrdDtlVO> list = new ArrayList<PrjPrdDtlVO>();
		list.add(dtl);
		ListPageVO<PrjPrdDtlVO> dtlData = new ListPageVO<PrjPrdDtlVO>(list, 0);
		view.addObject("id", id);
		view.addObject ("mtg", mtg);
		//view.addObject ("mtg", mtg);
		/*view.addObject("pledgeeSignDt", DateUtils.formatDateToString(mtg.getPledgeeSignDt(), DateUtils.YYYY_MM_DD));
		view.addObject("pledgorSignDt", DateUtils.formatDateToString(mtg.getPledgorSignDt(), DateUtils.YYYY_MM_DD));
		view.addObject("regAuthSignDt", DateUtils.formatDateToString(mtg.getRegAuthSignDt(), DateUtils.YYYY_MM_DD));*/
		view.addObject ("mtgDesc", mtgDesc);
		view.addObject ("certType", certType);
		view.addObject ("certNo", certNo);
		view.addObject ("cst", cst);
		view.addObject("guarStsCdList", guarStsCdList);
		view.addObject("guarTypCdList", guarTypCdList);
		view.addObject("mtgPsnTypCdList", mtgPsnTypCdList);
		view.addObject("yesNoList", yesNoList);
		view.addObject("dtlId", dtlId);
		view.addObject("detailFlag", detailFlag);
		view.addObject("dtlData", JSON.toJSONString(dtlData));
		view.addObject("buOrgCd", buOrgCd);
		view.addObject("no", no);
		view.addObject("lnkCompNm", lnkCompNm);
		view.addObject("cstTypCd", cstTypCd);
		view.addObject("mtgInsList", mtgInsList);//add 抵押名称与资方机构   by gengchunlan 20190731
		view.addObject("mtgInsJsonArray",JSONArray.fromObject(mtgInsList));//add 抵押名称与资方机构   by gengchunlan 20190731
		view.addObject("mtgWayList", mtgWayList);//add 抵押方式   by gengchunlan 20190731
		view.addObject("mtgWayJsonArray",JSONArray.fromObject(mtgWayList));
		if(null == mtg){
			KeyValueVO kv = mtgInsList.get(0);
			String nm_authCd = kv.getValue();
			String[] split = nm_authCd.split("_");
			view.addObject("pledgeeNmTemp", split[0]);
			view.addObject("pledgeeAuthNmTemp", split[1]);
		}
		if (null != mtg && !"2".equals(mtg.getMtgWayCd()) && (StringUtils.isEmpty(mtg.getPledgeeAuthNm()) || StringUtils.isEmpty(mtg.getPledgeeNm()))){
			KeyValueVO kv = mtgInsList.get(0);
			String nm_authCd = kv.getValue();
			String[] split = nm_authCd.split("_");
			BaseLogUtils.newLogger("mtgSplit=" + JSON.toJSONString(split)).info();
			//1-均为配置;2-全空；3-仅有签名;4-均为资方机构；
			if ("1".equals(kv.getKey())){
				mtg.setPledgeeAuthNm(split[1]);
				mtg.setPledgeeNm(split[0]);
			}else if ("3".equals(kv.getKey())){
				mtg.setPledgeeNm(split[0]);
			}else if ("4".equals(kv.getKey())){
				mtg.setPledgeeAuthNm("8");
				mtg.setPledgeeNm(insName);
			}
		}

		view.addObject("canUpdateMtg", request.getParameter("canUpdateMtg"));//是否可以维护抵押信息(1可以维护)

        view.addObject("checkDyPass", checkDyPass);
        view.addObject("prjId", prjId);
		BaseLogUtils.info(logger, "toModifyPage", "跳转到修改页面.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到添加附件
	 */
	@RequestMapping(value = "/toPrjPrdMtgAddFilePage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toPrjPrdMtgAddFilePage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		String detailFlag = request.getParameter("detailFlag");//是否为详细页面
		ModelAndView view = new ModelAndView("project/prjPrdMtg/prjPrdMtgAddFilePage");
		view.addObject("id", id);
		view.addObject("detailFlag", detailFlag);
		BaseLogUtils.info(logger, "toModifyPage", "跳转到添加附件页面.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String  cstNm = request.getParameter("cstNm");//客户名称
		String paySchNo = request.getParameter("paySchNo");//支付表号
		String guarStsCd = request.getParameter("guarStsCd");//抵押状态
		String mtgWayCd = request.getParameter("mtgWayCd");//抵押方式 add by gengchunlan 20190731
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(currentPage)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		PrjPrdMtgQueryCondition qc = new PrjPrdMtgQueryCondition();
		if (StringUtils.isNotEmpty(cstNm)) {
			qc.setCstNm(cstNm);
		}
		if (StringUtils.isNotEmpty(paySchNo)) {
			qc.setPaySchNo(paySchNo);
		}
		if (StringUtils.isNotEmpty(guarStsCd)) {
			qc.setGuarStsCd(guarStsCd);
		}
		if (StringUtils.isNotEmpty(mtgWayCd)) {
			qc.setMtgWayCd(mtgWayCd);
		}
		qc.setUsrId(CurrentThreadContext.getCurrentUserId());
		page.setCondition(qc);
        BaseLogUtils.info(logger,"initList","抵押信息分页查询调用贷前服务开始");
		Long startTime = System.currentTimeMillis();
		ResponseData responseData = productMortgateService.searchListPageByCondition(page.getEveryPage(),page.getCurrentPage(),qc,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd());
        Long endTime = System.currentTimeMillis();
        BaseLogUtils.info(logger,"initList","抵押信息分页查询调用贷前服务结束，耗时："+(endTime-startTime)+" ms" + " message: " + responseData.getMessage());
		List<PrjPrdMtgVO> voList = new ArrayList<>();
		ListPageVO<PrjPrdMtgVO> listPage =new ListPageVO<>();
		if(PreloanResultCodeEnum.SUCCESS.getCode().equals(responseData.getCode()) && null != responseData.getData()){
			PrjPrdMtgPageResponseDTO prjPrdMtgPageResponseDTO = (PrjPrdMtgPageResponseDTO) responseData.getData();
			List<PrjPrdMtgDTO> prjPrdMtgDTOList = prjPrdMtgPageResponseDTO.getList();
			if(null != prjPrdMtgDTOList && prjPrdMtgDTOList.size()>0){
				for(PrjPrdMtgDTO dto:prjPrdMtgDTOList){
					PrjPrdMtgVO vo = new PrjPrdMtgVO();
					BeanUtils.copyProperties(dto,vo);
					voList.add(vo);
				}
			}
			listPage = new ListPageVO<PrjPrdMtgVO>(voList, prjPrdMtgPageResponseDTO.getTotalCount());
		}

		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}

	/**
	 * 初始化抵押预警列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initWarnList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initWarnList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String cstNm = request.getParameter("cstNm");//客户名称
		String paySchNo = request.getParameter("paySchNo");//支付表号
		String guarStsCd = request.getParameter("guarStsCd");//抵押状态
		String mtgWayCd = request.getParameter("mtgWayCd");//抵押方式
		String insCode = request.getParameter("insCode");//三方机构
		String zgGuarStsCd = request.getParameter("zgGguarStsCd");//资方抵押状态
		String warnStsCd = request.getParameter("warnStsCd");//抵押预警状态
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}
		PrjPrdMtgQueryCondition qc = new PrjPrdMtgQueryCondition();
		if (StringUtils.isNotEmpty(cstNm)) {
			qc.setCstNm(cstNm);
		}
		if (StringUtils.isNotEmpty(paySchNo)) {
			qc.setPaySchNo(paySchNo);
		}
		if (StringUtils.isNotEmpty(guarStsCd)) {
			qc.setGuarStsCd(guarStsCd);
		}
		if (StringUtils.isNotEmpty(mtgWayCd)) {
			qc.setMtgWayCd(mtgWayCd);
		}
		if (StringUtils.isNotEmpty(insCode)) {
			qc.setInsCode(insCode);
		}
		if (StringUtils.isNotEmpty(zgGuarStsCd)) {
			qc.setZgGuarStsCd(zgGuarStsCd);
		}else {
			qc.setZgGuarStsCd("2");//未抵押
		}
		if (StringUtils.isEmpty(insCode)){	//若未选择资管，默认查询所有已配置的资管
			List<String> insCodeMtgList = new ArrayList<String>();
			Map<String,String> mtgEndMap = sysDictionaryApiService.searchGroupToMap(WebBaseConstant.SYS_SYS_CD, WebBaseConstant.SYS_P_ORG_CD, PrjPrdMtgConstant.CODE_MTG_ENDLINE_CD ) ;//资管抵押截止时限
			if (null!=mtgEndMap){
				for (Map.Entry<String, String> entry : mtgEndMap.entrySet()){
					String insCode_type = entry.getKey();
					insCodeMtgList.add(insCode_type.substring(0, insCode_type.indexOf("_")));
				}
				qc.setInsCodeList(insCodeMtgList);
			}
		}
		if (StringUtils.isNotEmpty(warnStsCd)) {
			qc.setWarnStsCd(warnStsCd);
		}
		qc.setUsrId(CurrentThreadContext.getCurrentUserId());
		page.setCondition(qc);
        BaseLogUtils.info(logger,"initList","抵押信息分页查询调用贷前服务开始");
		Long startTime = System.currentTimeMillis();
		ResponseData responseData = productMortgateService.searchListPageByCondition(page.getEveryPage(),page.getCurrentPage(),qc,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd());
        Long endTime = System.currentTimeMillis();
        BaseLogUtils.info(logger,"initList","抵押信息分页查询调用贷前服务结束，耗时："+(endTime-startTime)+" ms" + " message: " + responseData.getMessage());
		List<PrjPrdMtgVO> voList = new ArrayList<>();
		ListPageVO<PrjPrdMtgVO> listPage =new ListPageVO<>();
		String zgInsCode = "";
		//抵押预警字典集合
		Map<String,String> zgGuarStsMap = sysDictionaryApiService.searchGroupToMap(WebBaseConstant.SYS_SYS_CD, WebBaseConstant.SYS_P_ORG_CD,PrjPrdMtgConstant.CODE_MTG_ZGGUAR_CD ) ;//资管抵押状态
		Map<String,String> warnStsMap = sysDictionaryApiService.searchGroupToMap(WebBaseConstant.SYS_SYS_CD, WebBaseConstant.SYS_P_ORG_CD,PrjPrdMtgConstant.CODE_MTG_WARN_CD ) ;//抵押预警状态
		List<SysDictionaryDTO> mtgDicList = sysDictionaryApiService.searchGroup(WebBaseConstant.SYS_SYS_CD, WebBaseConstant.SYS_P_ORG_CD,PrjPrdMtgConstant.CODE_MTG_ENDLINE_CD);//资管抵押截止时限
		Map<String, String> insDaysMap = new HashMap<String, String>();
		for (SysDictionaryDTO dto : mtgDicList){
			insDaysMap.put(dto.getCode(), dto.getCodeAttr1()); //<机构_类型， 抵押截止时间>
		}
		//组织架构集合
		List<SysOrgDTO> list = this.sysOrgApiService.searchSysOrgListBy(CurrentThreadContext.getCurrentSysCd());
		Map<String, SysOrgDTO> buOrgCdMap = new HashMap<>();
		if (CollectionUtils.isNotEmpty(list)) {
			for (SysOrgDTO sysOrgDTO : list) {
				buOrgCdMap.put(sysOrgDTO.getOrgCd(), sysOrgDTO);
			}
		}
		SysOrgDTO sysOrgDTO = null;
		String orgCd = null;
		if(PreloanResultCodeEnum.SUCCESS.getCode().equals(responseData.getCode()) && null != responseData.getData()){
			PrjPrdMtgPageResponseDTO prjPrdMtgPageResponseDTO = (PrjPrdMtgPageResponseDTO) responseData.getData();
			List<PrjPrdMtgDTO> prjPrdMtgDTOList = prjPrdMtgPageResponseDTO.getList();
			if(null != prjPrdMtgDTOList && prjPrdMtgDTOList.size()>0){
				Set<Long> prjIdSet = new HashSet<Long>();
				Map<Long, PrjBscInfoVO> prjBscMap = new HashMap<Long, PrjBscInfoVO>();
				Map<Long, Integer> prdIsNewMap = new HashMap<Long, Integer>();
				for (PrjPrdMtgDTO mtgDTO : prjPrdMtgDTOList){
					prjIdSet.add(mtgDTO.getPrjId());
				}
				List<Long> prjIdList = new ArrayList<Long>(prjIdSet);//获得项目id集合并去重
				//抽出项目基础信息，项目产品基础信息
				PrjBscInfoQueryCondition prjBscQc = new PrjBscInfoQueryCondition();
				prjBscQc.setIdList(prjIdList);
				prjBscQc.setIsDel(0);
				List<PrjBscInfoVO> prjBscInfoVOS = this.prjBscInfoService.searchList(prjBscQc);
				BaseLogUtils.newLogger("prjBscInfoVOS:" + prjBscInfoVOS.size()).info();
				for (PrjBscInfoVO bscInfoVO : prjBscInfoVOS){
					prjBscMap.put(bscInfoVO.getId(), bscInfoVO);
				}
				PrjPrdBscInfoQueryCondition prdBscQc = new PrjPrdBscInfoQueryCondition();
				prdBscQc.setPrjIdList(prjIdList);
				prdBscQc.setIsDel(0);
				List<PrjPrdBscInfoVO> prjPrdBscInfoVOS = this.prjPrdBscInfoService.searchList(prdBscQc);
				BaseLogUtils.newLogger("prjPrdBscInfoVOS:" + prjPrdBscInfoVOS.size()).info();
				for (PrjPrdBscInfoVO prdBscInfoVO : prjPrdBscInfoVOS){
					prdIsNewMap.put(prdBscInfoVO.getPrjId(), prdBscInfoVO.getIsNew());
				}

				for(PrjPrdMtgDTO dto:prjPrdMtgDTOList){
					if (StringUtils.isBlank(dto.getWarnStsCd())) {
						dto.setWarnStsCd("");
						dto.setWarnStsCdNm("-");
					}
					if (StringUtils.isNotEmpty(dto.getWarnStsCd()) && StringUtils.isEmpty(dto.getWarnStsCdNm())){
						dto.setWarnStsCdNm(warnStsMap.get(dto.getWarnStsCd()));
					}
					if (null != dto.getDtlId()) {
						PrjPrdDtlVO prdDtlVO = this.prjPrdDtlService.selectById(dto.getDtlId());
//						PrjPrdBscInfoVO prdBscInfoVO = this.prjPrdBscInfoService.selectById(prdDtlVO.getPrjPrdId());
						String typeStr = "";
						int isNew = prdIsNewMap.get(prdDtlVO.getPrjId());
						if (null != prdIsNewMap.get(prdDtlVO.getPrjId()) ){
							typeStr = 1==isNew ? "new" : "esc";
						}
						String leftDaysStr = "";
						if (null != prdDtlVO && null != prdDtlVO.getPaySchId()) {
							String endLineDays = "";
							zgInsCode = dto.getInsCode() + "_" + typeStr;
							if (StringUtils.isNotEmpty(dto.getInsCode())) {
								endLineDays = insDaysMap.get(zgInsCode);
								if (StringUtils.isEmpty(dto.getZgGuarStsCd())) { //未抵押
									dto.setZgGuarStsCdNm(zgGuarStsMap.get("2"));
								}
							}
							if (zgGuarStsMap.containsKey(dto.getZgGuarStsCd())) {
								dto.setZgGuarStsCdNm(zgGuarStsMap.get(dto.getZgGuarStsCd()));
							}
							PrjPrdPaySchMVO paySchMVO = this.prjPrdPaySchMService.selectById(prdDtlVO.getPaySchId());
							if (null != paySchMVO && null != paySchMVO.getThdPayDt()) {
								dto.setThdPayDt(paySchMVO.getThdPayDt());//资方放款时间
								if (StringUtils.isNotEmpty(endLineDays)) {
									Date endDay = DateUtils.getDateAddDate(paySchMVO.getThdPayDt(), DateUtils.DAY, Integer.parseInt(endLineDays));
									dto.setMgtEndDate(DateUtils.formatDateToString(endDay, DateUtils.YYYY_MM_DD));//资方抵押截至日期
									//抵押时效剩余天数=抵押截止日期-当前日期
									Long leftDays = DateUtils.getDaysBetweenTwoDates(new Date(), endDay);
									if (leftDays < 0) {
										leftDays = 0L;
									}
									leftDaysStr = leftDays.toString();
								}
							}
						}

						PrjPrdMtgVO vo = new PrjPrdMtgVO();
						BeanUtils.copyProperties(dto, vo);

						vo.setLeftDays(leftDaysStr);//抵押时效剩余天数
						PrjBscInfoVO prjBscInfoVO = prjBscMap.get(dto.getPrjId());
						if (null!=prjBscInfoVO && buOrgCdMap.containsKey(prjBscInfoVO.getCstMgrOrgCd())) {
							vo.setCstMgrNm(prjBscInfoVO.getCstMgrNm());//客户经理名称
							sysOrgDTO = buOrgCdMap.get(prjBscInfoVO.getBuOrgCd());
							vo.setBuOrgCdNm(sysOrgDTO.getOrgNm());//事业部名称
							sysOrgDTO = buOrgCdMap.get(prjBscInfoVO.getCstMgrOrgCd());//客户经理所属组织架构代码
							orgCd = sysOrgDTO.getOrgCd();
							while (orgCd.length() > 8) {
								if ("4".equals(sysOrgDTO.getOrgTypCd())) {//分公司
									vo.setCyOrgCdNm(sysOrgDTO.getOrgNm());
								} else if ("3".equals(sysOrgDTO.getOrgTypCd())) {//省公司
									vo.setPrOrgCdNm(sysOrgDTO.getOrgNm());
									break;
								}
								orgCd = orgCd.substring(0, orgCd.length() - 4);
								if (buOrgCdMap.containsKey(orgCd)) {
									sysOrgDTO = buOrgCdMap.get(orgCd);
								} else {
									break;
								}
							}
						}
						voList.add(vo);
					}
				}
			}
			listPage = new ListPageVO<PrjPrdMtgVO>(voList, prjPrdMtgPageResponseDTO.getTotalCount());
		}
		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}

	/**
	 * 删除数据
	 */
	@RequestMapping(value = "/removeByIds.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO removeByIds(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String ids = request.getParameter("ids");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(ids)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		List<Long> idList = new ArrayList<Long>();
		JSONArray idsArray = JSONArray.fromObject(ids);
		for (Object object : idsArray) {
			idList.add(Long.valueOf(object.toString()));
		}
		try {
			DeleteByIdsProjProdMortgageRequest prodMortgageRequest = new DeleteByIdsProjProdMortgageRequest();
			prodMortgageRequest.setIds(idList);
			BaseLogUtils.info(logger,"removeByIds","pre-loan 抵押删除 服务调用开始");
			Long startTime = System.currentTimeMillis();
			ResponseData responseData = this.productMortgateService.removeByIds(prodMortgageRequest);
			Long endTime = System.currentTimeMillis();
			BaseLogUtils.info(logger,"removeByIds","pre-loan 抵押删除 服务调用结束，耗时："+(endTime-startTime)+" ms" + " message: " + responseData.getMessage());
			if(!ResponseData.SUCCESS_CODE.equals(responseData.getCode())){
				throw new BaseException(BaseExceptionConstant.DATABASE_0201_NAME,"删除数据失败");
			}
			BaseLogUtils.info(logger, "removeById", "删除数据.[ids="+ids+"]", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "removeById", "删除数据失败.[ids="+ids+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "removeById", "删除数据失败.[ids="+ids+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}

	/**
	 * 得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.error(logger, "getById", "获取数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			PrjPrdMtgVO vo = this.prjPrdMtgService.selectById(Long.valueOf(id));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getById", "获取数据,数据不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
			BaseLogUtils.info(logger, "getById", "获取数据.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getById", "获取失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getById", "获取失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}


	/**
	 * 修改质押状态 系统运维
	 */
	@RequestMapping(value = "/changeGuarSts4Sys.do", method = {RequestMethod.POST})
	@ResponseBody
	public Object changeGuarSts4Sys(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String guarStsCd = request.getParameter("guarStsCd");//抵押状态
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		PrjPrdMtgVO entity = null;
		Long mtgId = null;
		try {
			if (StringUtils.isNotBlank(id)) {
				entity = new PrjPrdMtgVO();
				if (StringUtils.isNotBlank(guarStsCd)) {
					entity.setGuarStsCd(guarStsCd);
				}
			}
			entity.setId(Long.valueOf(id));
			PrjPrdMtgDTO prjPrdMtgDTO = new PrjPrdMtgDTO();
			BeanUtils.copyProperties(entity,prjPrdMtgDTO);
			BaseLogUtils.info(logger,"changeGuarSts","pre-loan 抵押更新调用贷前服务开始");
			Long startTime = System.currentTimeMillis();
			ResponseData responseData = productMortgateService.modifyProjProdMortgage(prjPrdMtgDTO);
			Long endTime = System.currentTimeMillis();
			BaseLogUtils.info(logger,"changeGuarSts","pre-loan 抵押更新调用贷前服务结束，耗时："+(endTime-startTime)+" ms" + " message: " + responseData.getMessage());
//			this.prjPrdMtgService.modifyGuarSts(entity);
			result.setData(mtgId);
			result.setSuccess(BaseConstant.IS_YESNO_YES);
			BaseLogUtils.info(logger, "changeGuarSts", "修改数据.[id=" + mtgId + "] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "changeGuarSts", "修改数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "changeGuarSts", "修改数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}


	/**
	 * 修改质押状态
	 */
	@RequestMapping(value = "/changeGuarSts.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object changeGuarSts(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String  guarStsCd = request.getParameter("guarStsCd");//抵押状态
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		PrjPrdMtgVO entity = null;
		Long mtgId = null;
		try {
			if(StringUtils.isNotBlank(id)){
				entity = new PrjPrdMtgVO();
				if(StringUtils.isNotBlank(guarStsCd)){
					if(guarStsCd.equals(PrjPrdMtgConstant.CODE_GUAR_STS_CD_NONE)||guarStsCd.equals(PrjPrdMtgConstant.CODE_GUAR_STS_CD_REL_MTG)){
						entity.setGuarStsCd(PrjPrdMtgConstant.CODE_GUAR_STS_CD_MTG);
						result.setInfo("抵押成功！");
					}else{
						entity.setGuarStsCd(PrjPrdMtgConstant.CODE_GUAR_STS_CD_REL_MTG);
						result.setInfo("解押成功！");
					}
				}
				entity.setId(Long.valueOf(id));
				//entity.setGuarStsCd(PrjPrdMtgConstant.CODE_GUAR_STS_CD_REL_MTG);
//				this.prjPrdMtgService.modifyGuarSts(entity);
				PrjPrdMtgDTO prjPrdMtgDTO = new PrjPrdMtgDTO();
				BeanUtils.copyProperties(entity,prjPrdMtgDTO);
				BaseLogUtils.info(logger,"changeGuarSts","pre-loan 抵押信息更新调用贷前服务开始");
				Long startTime = System.currentTimeMillis();
				ResponseData responseData = productMortgateService.modifyProjProdMortgage(prjPrdMtgDTO);
				Long endTime = System.currentTimeMillis();
				BaseLogUtils.info(logger,"changeGuarSts","pre-loan 抵押信息更新调用贷前服务结束，耗时："+(endTime-startTime)+" ms" + " message: " + responseData.getMessage());
			}
			result.setData(mtgId);
			result.setSuccess(BaseConstant.IS_YESNO_YES);
			BaseLogUtils.info(logger, "changeGuarSts", "修改数据.[id="+mtgId+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "changeGuarSts", "修改数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "changeGuarSts", "修改数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}
	/**
	 * 新增
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String YD = request.getParameter("YD");//(tsn)
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		PrjPrdMtgVO entity = null;
		Long mtgId = null;
		try {
			entity = this.getRequestParam(request);
			if(StringUtils.isNotBlank(id)){
				//修改
				 mtgId = Long.valueOf(id);
				  this.prjPrdMtgService.modify(entity);
					result.setSuccess(BaseConstant.IS_YESNO_YES);
					result.setInfo(SysLogConstant.LOG_CMM_UPDATE_SUCC);
			}else{
				//添加
				entity.setIsDel(BaseConstant.IS_YESNO_NO);
				entity.setAudStsCd(FlowConstant.FLOW_CHECK_STATE_NON);
				entity.setCrtTm(new  Date());
				entity.setGuarStsCd(PrjPrdMtgConstant.CODE_GUAR_STS_CD_NONE);//未抵押
				entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
				mtgId = this.prjPrdMtgService.add(entity);
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo(SysLogConstant.LOG_CMM_ADD_SUCC);
			}
			result.setData(mtgId);
			BaseLogUtils.info(logger, "add", "新增数据.[id="+mtgId+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "add", "新增数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "add", "新增数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}
	//保存抵押权人名称
	@RequestMapping(value = "/addpledgeeAuthNm.do", method = { RequestMethod.POST })
	@ResponseBody
	private Object addpledgeeAuthNm(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String pledgeeAuthNm = request.getParameter("pledgeeAuthNm");//抵押权人名称
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		PrjPrdMtgVO entity = new PrjPrdMtgVO();
		Long mtgId = null;
		try {
			if(StringUtils.isNotBlank(id)){
				 mtgId = Long.valueOf(id);
				 entity.setId(mtgId);
				 if(StringUtils.isNotBlank(pledgeeAuthNm)){
						entity.setPledgeeAuthNm(pledgeeAuthNm);//抵押权人名称
					}
				 this.prjPrdMtgService.modify(entity);
				 result.setSuccess(BaseConstant.IS_YESNO_YES);
				 result.setInfo(SysLogConstant.LOG_CMM_UPDATE_SUCC);
			}else{
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"抵押信息为空！");
			}
			result.setData(mtgId);
			BaseLogUtils.info(logger, "add", "修改抵押权人名称.[id="+mtgId+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "add", "修改抵押权人名称.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "add", "修改抵押权人名称.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		
		return result;
	}
	private PrjPrdMtgVO getRequestParam(HttpServletRequest request) {
		PrjPrdMtgVO mtg = new PrjPrdMtgVO();
		String recNo = request.getParameter("recNo");// 登记编号
		String mtgDeadline = request.getParameter("mtgDeadline");//抵押期限
		String isWithoutDay = request.getParameter("isWithoutDay");//是否无期限抵押
		String mtgPsnTypCd = request.getParameter("mtgPsnTypCd");//抵押人类型
		String sortNo = request.getParameter("sortNo");//抵押序号
		String guarTypCd = request.getParameter("guarTypCd");//抵押物种类
		String guarDesc = request.getParameter("guarDesc");//抵押物描述
		String pledgorNm = request.getParameter("pledgorNm");//抵押人名称
		String pledgorSignDt = request.getParameter("pledgorSignDt");//抵押人签字日期
		String pledgeeNm = request.getParameter("pledgeeNm");//抵押权人
		String pledgeeSignDt = request.getParameter("pledgeeSignDt");//抵押权人签字日期
		String regAuthSignDt = request.getParameter("regAuthSignDt");//登记机关签字日期
		String licOrgId =  request.getParameter("licOrgId");//登记机关
		String dtlId = request.getParameter("dtlId");//
		String fileParams = request.getParameter("fileParams");//文件资料
		String DY = request.getParameter("DY");//抵押(tsn)
		// 抵押权人名称（姓名）
		String pledgeeAuthNm = request.getParameter("pledgeeAuthNm");
		String mtgWayCd = request.getParameter("mtgWayCd");//抵押方式  add by gengchunlan 20190731
		String rgnPrCd = request.getParameter("rgnPrCd");//省
		String rgnCyCd =request.getParameter("rgnCyCd"); //市
		//项目ID
		String prjId =request.getParameter("prjId");
		if (StringUtils.isNotBlank(rgnPrCd)) {
			mtg.setRgnPrCd(rgnPrCd);
		}
		if (StringUtils.isNotBlank(rgnCyCd)) {
			mtg.setRgnCyCd(rgnCyCd);
		}
		if (StringUtils.isNotBlank(pledgeeAuthNm)) {
			mtg.setPledgeeAuthNm(pledgeeAuthNm);
		}else {
			mtg.setPledgeeAuthNm("");
		}
		if(StringUtils.isNotBlank(fileParams)){
			List<SysUlFilesRecVO> fileList = new ArrayList<SysUlFilesRecVO>();
			if (StringUtils.isNotBlank(fileParams)) {
				fileList = JSON.parseArray(fileParams, SysUlFilesRecVO.class);
				if(CollectionUtils.isNotEmpty(fileList)){
					for (SysUlFilesRecVO sysUlFilesRecVO : fileList) {
						sysUlFilesRecVO.setAbsLocPath(PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_ROOT_PATH)+sysUlFilesRecVO.getFilePath());
					}

				}
			}
			mtg.setFileList(fileList);
		}
		if(StringUtils.isNotBlank(dtlId)){
			mtg.setId(Long.valueOf(dtlId));
		}
		if(StringUtils.isNotBlank(DY)){//抵押(tsn)
			mtg.setPledgeState(DY);
			if ("2".equals(mtgWayCd)){//当抵押方式为无法抵押，抵押状态修改为无法抵押
				mtg.setGuarStsCd(PrjPrdMtgConstant.CODE_GUAR_STS_CD_FOR_MTG);
			}else {//当抵押方式为正常抵押、资方机构、上户自有公司时，抵押状态修改为已抵押
				mtg.setGuarStsCd(PrjPrdMtgConstant.CODE_GUAR_STS_CD_MTG);
			}

		}
		//modify 当抵押方式选择为无法抵押、上户自有公司时，保留抵押方式、登记证编号必填校验。其他必填证去掉 by gengchunlan 20190801
		if(StringUtils.isBlank(mtgWayCd)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"抵押方式不能为空！");
		}
		String isFlag="1";
		if("2".equals(mtgWayCd) || "3".equals(mtgWayCd)){//2 无法抵押   3 上户自有公司
			isFlag="2";
		}
		if("1".equals(isFlag)){
			if(StringUtils.isBlank(pledgorNm)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"抵押人名称不能为空！");
			}
			if(StringUtils.isBlank(pledgeeNm)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"抵押权人名称不能为空！");
			}

			if(StringUtils.isBlank(pledgorSignDt)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"抵押人签字日期不能为空！");
			}/*else{
				Date pledgorSignDate = DateUtils.formatStringToDate(pledgorSignDt, DateUtils.YYYY_MM_DD);
				if(DateUtils.before( DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD),pledgorSignDate)){
					throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,"抵押人签字日期不能在当前日期之前");
				}
			}*/
			if(StringUtils.isBlank(pledgeeSignDt)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"抵押权人签字日期不能为空！");
			}/*else{
				Date pledgeeSignDate = DateUtils.formatStringToDate(pledgeeSignDt, DateUtils.YYYY_MM_DD);
				if(DateUtils.before( DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD),pledgeeSignDate)){
					throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,"抵押权人签字日期不能在当前日期之前");
				}
			}*/
			if(StringUtils.isBlank(regAuthSignDt)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600," 登记机关签字日期不能为空！");
			}/*else{
				Date regAuthSignDate = DateUtils.formatStringToDate(regAuthSignDt, DateUtils.YYYY_MM_DD);
				if(DateUtils.before( DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD),regAuthSignDate)){
					throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,"登记机关签字日期不能在当前日期之前");
				}
			}*/
			if(StringUtils.isBlank(licOrgId)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"登记机关不能为空！");
			}
			if(StringUtils.isBlank(mtgPsnTypCd)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"抵押人不能为空！");
			}
			if(StringUtils.isBlank(guarTypCd)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"抵押物种类不能为空！");
			}

		}

		if(StringUtils.isNotBlank(licOrgId)){
			mtg.setLicOrgId(Long.valueOf(licOrgId));
		}
		if(StringUtils.isBlank(recNo)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"登记编号不能为空！");
		}
		mtg.setRecNo(recNo);
		
		if(StringUtils.isNotBlank(mtgPsnTypCd)){
			mtg.setMtgPsnTypCd(mtgPsnTypCd);
		}
				
		if(StringUtils.isBlank(sortNo)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"抵押序号不能为空！");
		}else{
			if(!(StringUtils.isNumeric(sortNo)&&Integer.valueOf(sortNo)>=0&&Integer.valueOf(sortNo)<100)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"抵押序号必须为小100的正整数！");
			}
		}
		mtg.setSortNo(sortNo);

		if(StringUtils.isNotBlank(mtgDeadline)){
			mtg.setMtgDeadline(DateUtils.formatStringToDate(mtgDeadline, DateUtils.YYYY_MM_DD));
	    }
		/*if(StringUtils.isNotBlank(mtgDeadline)){
			Date mtgDeadlineDt = DateUtils.formatStringToDate(mtgDeadline, DateUtils.YYYY_MM_DD);
			if(DateUtils.before( DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD),mtgDeadlineDt)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_604,"抵押期限不能在当前日期之前");
			}
			mtg.setMtgDeadline(DateUtils.formatStringToDate(mtgDeadline, DateUtils.YYYY_MM_DD));
		}*/
		if(StringUtils.isNotBlank(isWithoutDay)){
			if(isWithoutDay.equals("true")){
				mtg.setIsWithoutDay(BaseConstant.IS_YESNO_YES);	
			}else{
				mtg.setIsWithoutDay(BaseConstant.IS_YESNO_NO);
			}
		}else{
			mtg.setIsWithoutDay(BaseConstant.IS_YESNO_NO);
		}
			mtg.setGuarDesc(guarDesc);
			mtg.setPledgorNm(pledgorNm);
		if(StringUtils.isNotBlank(pledgorSignDt)){
			mtg.setPledgorSignDt(DateUtils.formatStringToDate(pledgorSignDt, DateUtils.YYYY_MM_DD));
		}	
			mtg.setPledgeeNm(pledgeeNm);
		if(StringUtils.isNotBlank(pledgeeSignDt)){
			mtg.setPledgeeSignDt(DateUtils.formatStringToDate(pledgeeSignDt, DateUtils.YYYY_MM_DD));
		}		
				
		if(StringUtils.isNotBlank(regAuthSignDt)){
			mtg.setRegAuthSignDt(DateUtils.formatStringToDate(regAuthSignDt, DateUtils.YYYY_MM_DD));
		}
		if(StringUtils.isNotBlank(mtgWayCd)){//add 抵押方式 by gengchunlan 20190801
			mtg.setMtgWayCd(mtgWayCd);
		}
		if(StringUtils.isNotEmpty(prjId)){
			mtg.setPrjId(Long.valueOf(prjId));
		}
		mtg.setGuarTypCd(guarTypCd);
		mtg.setMdfTm(new Date());
		mtg.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		return mtg;
	}

	/**
	 * 修改
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modify", "修改数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		PrjPrdMtgVO entity = null;
		try {
			entity = new PrjPrdMtgVO();
			entity.setId(Long.valueOf(id));
			//entity.setName(name);
			//TODO ADD PARAM
			boolean success = this.prjPrdMtgService.modify(entity);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				BaseLogUtils.info(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "modify", "修改成功.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	/**
	 * 获取抵押信息
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getPrjPrdMtgList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getPrjPrdMtgList(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String recNo = request.getParameter("recNo");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(recNo)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			return result;
		}
		boolean flag  = false;
		try {
			cn.fl.project.condition.PrjPrdMtgQueryCondition qc = new cn.fl.project.condition.PrjPrdMtgQueryCondition();
			qc.setRecNo(recNo);
			flag = this.prjPrdMtgService.checkPrjPrdMtgRecNoExist(qc);
			if(flag){
				result.setSuccess(BaseConstant.IS_YESNO_YES);
			}else{
				result.setSuccess(BaseConstant.IS_YESNO_NO);
			}
			BaseLogUtils.info(logger, "checkPrjPrdMtgRecNoExist", "获取数据.[flag="+flag+"]", CurrentThreadContext.getCurrentUserName());
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getById", "获取失败"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getById", "获取失败"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	

	/**
	 * 验证登记证-抵押我司页
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/checkMtgPage.do")
	@ResponseBody
	public Object checkMtgPage(HttpServletRequest request) throws BaseException {
		
		String prjPrdDtlId = request.getParameter("prjPrdDtlId");
		String fileId = request.getParameter("fileId");
		String orgCd = request.getParameter("orgCd");
		
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO);
//		result.setData("confirmPass");
		if(StringUtils.isEmpty(prjPrdDtlId) || StringUtils.isEmpty(fileId) || 
				StringUtils.isEmpty(orgCd)){
			result.setInfo(SysLogConstant.LOG_CMM_PARAM_IS_BAD);
			return result;
		}
		
		try {
			result = this.prjPrdMtgService.checkMtgPage(prjPrdDtlId,fileId,orgCd);
		}catch(Exception ex) {
			ex.printStackTrace();
			result.setInfo("验证登记证-抵押我司页异常: "+ex.getMessage());
			BaseLogUtils.error(logger, "", "验证登记证-抵押我司页异常: "+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	@RequestMapping(value = "/modifyFileRem.do")
	@ResponseBody
	public Object modifyFileRem(HttpServletRequest request) throws BaseException {

		String fileId = request.getParameter("fileId");

		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO);
		if (StringUtils.isEmpty(fileId)) {
			result.setInfo(SysLogConstant.LOG_CMM_PARAM_IS_BAD);
			return result;
		}

		try {
			result = this.prjPrdMtgService.modifyFileRem(fileId);
		} catch (Exception ex) {
			ex.printStackTrace();
			result.setInfo("====modifyFileRem失败: " + ex.getMessage());
			BaseLogUtils.error(logger, "", "====modifyFileRem失败: " + ex.getMessage(),
					CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
}

